class Player(object):
    numbers = 0 # 类属性
    def __init__(self, name,age,city): # 初始化函数
        self.name = name # 实例属性
        self.age = age
        self.city = city
        Player.numbers += 1

    def show(self): # 实例的方法
        print('我是荣耀王者的第%d个玩家，我的名字是%s，我来自%s' % (Player.numbers,self.name,self.city))

    @classmethod
    def get_players(cls): # 类方法
        print('荣耀王者的用户数量已经达到了%d人' % cls.numbers)

jj = Player("林俊杰",30,"新加坡")

# 调用实例方法
jj.show()

# 调用类方法
Player.get_players()


print("🍎" * 20)

class Weapon(object):
    numbers = 0 # 类属性
    max_damage = 10000 # 类属性
    level = ["钻石","星耀","王者","荣耀"] # 类属性
    all_weapons = []
    def __init__(self,name,damage,level):
        self.name = name
        self.damage = damage
        self.level = level
        Weapon.numbers += 1
        if damage > Weapon.max_damage:
            raise Exception("最大的伤害值是10000，请重试")
        if level not in Weapon.level:
            raise Exception("段位设置错误")

        Weapon.all_weapons.append(self)

    @classmethod # 类方法
    def get_max_damage(cls):
         max_damage = 0
         for w in cls.all_weapons:
             if w.damage > max_damage:
                 max_damage = w.damage
         return max_damage


gun = Weapon('magic',2000,"王者")
arrow = Weapon('arrow', 1000, "荣耀")
print(Weapon.get_max_damage())


"""

类方法
类属性
实例方法
实例属性

"""




